package com.cindata

import com.cindata.dictionary.*

class BatchEstate
{

    String evaluateCode
    ExecStatusDict evaluateStatue
    Date evaluateDate
    Account latestEvaluateAccount

    Date createdDate = new Date()
    Date modifiedDate = new Date()

    String failReason

    static belongsTo = [batch: EstateImportBatch, estate: Estate]

    static mapping = {
        cache true
    }

    static constraints = {
        evaluateCode nullable: true, blank: true
        latestEvaluateAccount nullable: true, blank: true
        evaluateStatue nullable: true, blank: true
        createdDate nullable: true, blank: true
        modifiedDate nullable: true, blank: true
        evaluateDate nullable: true, blank: true

        failReason maxSize: 255, nullable: true, blank: true, comment: '评估失败原因'
    }

    def beforeUpdate()
    {
        modifiedDate = new Date()
    }

    def afterUpdate()
    {
        this.updateMatchNum()
    }

    // 更新匹配记录数量
    def updateMatchNum()
    {
        this.batch.updateBatchEstateCount()
    }
}